package ${packageName}.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import ${packageName}.mapper.${upperFirstLetterName}Mapper;
import ${packageName}.model.${upperFirstLetterName};
import ${packageName}.service.${upperFirstLetterName}Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ${packageName}.common.Page;

@Service
public class ${upperFirstLetterName}ServiceImpl implements ${upperFirstLetterName}Service{

	private static final Logger logger = LoggerFactory.getLogger(${upperFirstLetterName}Service.class);

	@Autowired
	private ${upperFirstLetterName}Mapper ${lowerFirstLetterName}Mapper;

	public Integer save(${upperFirstLetterName} ${lowerFirstLetterName}){
		return ${lowerFirstLetterName}Mapper.save(${lowerFirstLetterName});
	}

	@Override
	public ${upperFirstLetterName} getBy${upperFirstLetterPrimaryKey}(${primaryKeyType} ${primaryKey}){
		return ${lowerFirstLetterName}Mapper.getBy${upperFirstLetterPrimaryKey}(${primaryKey});
	}
	@Override
	public void deleteBy${upperFirstLetterPrimaryKey}(${primaryKeyType} ${primaryKey}){
		${lowerFirstLetterName}Mapper.deleteBy${upperFirstLetterPrimaryKey}(${primaryKey});
	}
	@Override
	public void update(${upperFirstLetterName} ${lowerFirstLetterName}){
		${lowerFirstLetterName}Mapper.update(${lowerFirstLetterName});
	}

	@Override
	public Integer count(){
	    return ${lowerFirstLetterName}Mapper.count();
	}

	@Override
	public List<${upperFirstLetterName}> list(){
		return ${lowerFirstLetterName}Mapper.list();
	}

	@Override
	public Page<${upperFirstLetterName}> page(int pageNo, int pageSize) {
		Page<${upperFirstLetterName}> page = new Page<>();
        int start = (pageNo-1)*pageSize;
        page.setPageSize(pageSize);
        page.setStart(start);
        page.setResult(${lowerFirstLetterName}Mapper.page(start,pageSize));
        page.setTotalCount(${lowerFirstLetterName}Mapper.count());
        return page;
	}
	
}